<h1>Sound</h1>

<p>The Sound data structure identifies a sound (previously defined using DefineSound) 
and controls how it is played. Sound defines how the sound fades in and out, 
whether it is repeated as well as specifying an envelope that provides a finer 
degree of control over the levels at which the sound is played.</p>

<table>

<tr>
<th nowrap>Field Name</th>
<th>Type</th>
<th>Size</th>
<th>Description</th>
</tr>

<tr>
<td nowrap valign="top">identifier</td>
<td nowrap valign="top">unsigned int</td>
<td nowrap valign="top" align="right">16</td>
<td>The identifier, in the range 1..65535, of the sound definition (DefineSound) that 
contains the sound data.</td>
</tr>

<tr>
<td nowrap valign="top">mode</td>
<td nowrap valign="top">unsigned bit</td>
<td nowrap valign="top" align="right">4</td>
<td>Controls how the sound is played, either: Start - start playing the sound, 
Continue - start playing the sound if it is not already playing and Stop - stop 
playing the sound.</td>
</tr>

<tr>
<td nowrap valign="top">hasEnvelopes</td>
<td nowrap valign="top">boolean</td>
<td nowrap valign="top" align="right">1</td>
<td>Is an envelope defined for the sound.</td>
</tr>

<tr>
<td nowrap valign="top">hasLoopCount</td>
<td nowrap valign="top">boolean</td>
<td nowrap valign="top" align="right">1</td>
<td>Is the number of time a sound is played defined.</td>
</tr>

<tr>
<td nowrap valign="top">hasOutPoint</td>
<td nowrap valign="top">boolean</td>
<td nowrap valign="top" align="right">1</td>
<td>Is the sample number at which the sound starts to fade defined.</td>
</tr>

<tr>
<td nowrap valign="top">hasInPoint</td>
<td nowrap valign="top">boolean</td>
<td nowrap valign="top" align="right">1</td>
<td>Is the sample number at which the sound reaches full volume defined.</td>
</tr>

<tr>
<td nowrap valign="top">inPoint</td>
<td nowrap valign="top">unsigned int</td>
<td nowrap valign="top" align="right">32</td>
<td>The sample number that the sound increases in volume to until full volume 
is reached. Optional. Set to 0 if the sound does not fade in.</td>
</tr>

<tr>
<td nowrap valign="top">outPoint</td>
<td nowrap valign="top">unsigned int</td>
<td nowrap valign="top" align="right">32</td>
<td>The sample number at which the that the sound starts to fades until the 
sound has finished playing. Optional. Set to 0 if the sound does not fade out.</td>
</tr>

<tr>
<td nowrap valign="top">loopCount</td>
<td nowrap valign="top">unsigned int</td>
<td nowrap valign="top" align="right">16</td>
<td>The number of times the sound is repeated. Optional. Must be at least 1 if 
a sound is being played. Set to 0 if a sound is being stopped.</td>
</tr>

<tr>
<td nowrap valign="top">envelopeCount</td>
<td nowrap valign="top">unsigned int</td>
<td nowrap valign="top" align="right">8</td>
<td>The points defined for the sound envelope.</td>
</tr>

<tr>
<td nowrap valign="top">envelopes</td>
<td nowrap valign="top">Envelope</td>
<td nowrap valign="top" align="right">[envelopeCount]</td>
<td>An array of Envelopes that control how the sound is played. 
Optional. May be set to null or an empty array if no envelope is defined.</td>
</tr>

</table>

<p>Not all the attributes are required to play a sound. Only the identifier and 
the mode is required. The other attributes are optional and may be added as a 
greater degree of control is required. The inPoint and outPoint attributes may 
be set to zero if the sound does not fade in or out respectively. The loopCount 
may be set to zero if a sound is being stopped. The envelopes array may be left 
empty if no envelope is defined for the sound. The class provides different 
constructors to specify different sets of attributes.</p>

<p>The in and out point specify the sample number which marks the point in time 
at which the sound stops increasing or starts decreasing in volume respectively. 
Sounds are played by the Flash player at 44.1KHz so the sample number also 
indicates the time when the total number of samples in the sound is taken into 
account.</p>

<h2>History</h2>

<p>The Sound data structure is based on the SoundInfo data structure from the Macromedia 
Flash (SWF) File Format Specification. However it also contains the identifier 
for the sound which is a separate attribute in the data structures defined in 
the specification that contain SoundInfo data.</p>
